home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Development Platforms / Apple II / Apple II Sample Code / APW.SC / SC07Jiffy.Wind / Jiffy.Stds.asm < prev    next >
Encoding:
Assembly Source File  |  1990-06-18  |  10.7 KB  |  312 lines  |  [TEXT/pdos]

  1. *******************************************************************************
  2. *
  3. InitTools           start
  4. *
  5. * Description:      Load and initialize the tools needed. Errors are detected
  6. *                   and FatalError is called if any occur. If there aren't any
  7. *                   errors, the list of menu templates is read and the menu-
  8. *                   bar is created.
  9. *
  10. *
  11. * Inputs:           NONE
  12. *
  13. * Outputs:          NONE
  14. *
  15. * External Refs:
  16. *                   Import FatalError
  17. *
  18. * Entry Points:     NONE
  19. *
  20. *******************************************************************************
  21.                     using Globals
  22.  
  23. ;
  24. ;   Tool Direct page offsets here
  25. ;
  26. QDDPage             equ $0000
  27. EMDPage             equ QDDPage+$0300
  28. CtlDPage            equ EMDPage+$0100
  29. MenuDPage           equ CtlDPage+$0100
  30. LEDPage             equ MenuDPage+$0100
  31. FMDPage             equ LEDPage+$0100
  32. ToolDPSize          equ FMDPage+$0100
  33.  
  34.                     phk                 ; Save program bank register and
  35.                     plb                 ; load it as the data bank register
  36.  
  37.                     tdc
  38.                     sta MyDP            ; Save direct register
  39.  
  40.                     _TLStartup          ; Start Tool Locator
  41.  
  42.                     pha                 ; Space for result
  43.                     _MMStartup          ; Start memory manager
  44.                     PullWord MyID       ; Save it for later use
  45.  
  46.                     _MTStartup          ; Start up Misc Tools
  47.  
  48.                     _IMStartup          ; Start integer math toolset
  49.  
  50.                     PushLong #ToolTable ; Pointer to Tool table
  51.                     _LoadTools          ; Load all RAM based tools
  52.                     bcc IT0005          ; Carry clear means no error
  53.                     brl FatalError      ; Tools can't be loaded. Fatal error!
  54.  
  55. IT0005              ANOP
  56.  
  57. ; Get memory for Tool Direct pages
  58.  
  59.                     pha                 ; Room for result
  60.                     pha
  61.                     PushLong #ToolDPSize ; Number of bytes needed
  62.                     PushWord MyID       ; ID of this application
  63.                     PushWord #attrLocked+attrFixed+attrPage+attrBank
  64.                     PushLong #0         ; Allocate them in bank 0
  65.                     _NewHandle
  66.                     bcc IT0010          ; Test carry for error
  67.                     brl FatalError      ; If no memory we got a fatal error!
  68.  
  69. IT0010              PullLong DPHandle   ; Retrieve handle to our DPage area
  70.  
  71.                     lda [DPHandle]      ; Dereference the handle to get a ptr
  72.                     sta DPPointer       ; to our direct page area and save it.
  73.  
  74.                     PushWord DPPointer  ; QuickDraw uses 3 pages of Dpage
  75.                     PushWord #ScreenMode ; Used to set all master SCB's
  76.                     PushWord #0         ; Zero means use default buf size
  77.                     PushWord MyID       ; Application ID for allocating data
  78.                     _QDStartup          ; Start QuickDraw, turn on SHR Screen
  79.                     bcc IT0015
  80.                     brl FatalError      ; If it can't be started then bomb
  81.  
  82. IT0015              ANOP
  83.                     _QDAuxStartup
  84.                     
  85.                     lda DPPointer       ; Create address for Event Mgr DPage by
  86.                     clc                 ; loading in the pointer to the start
  87.                     adc #EMDPage        ; of DPage and adding Evt Mgr offset.
  88.                     pha                 ; Now push it on the stack.
  89.                     PushWord #20        ; Size of event queue.
  90.                     PushWord #0         ; MouseClamp values.
  91.                     PushWord #ScreenWidth ; These will clamp mouse to screen
  92.                     PushWord #0         ; area only.
  93.                     PushWord #200
  94.                     PushWord MyID
  95.                     _EMStartup          ; Start the event manager
  96.                     bcc IT0020
  97.                     brl FatalError      ; Event manager is also a must
  98. IT0020              ANOP
  99.                     PushWord MyID
  100.                     _WindStartup
  101.                     bcc IT0025
  102.                     brl FatalError
  103. IT0025              ANOP
  104.                     PushWord MyID
  105.                     lda DPPointer
  106.                     clc
  107.                     adc #CtlDPage
  108.                     pha
  109.                     _CtlStartup
  110.                     bcc IT0030
  111.                     brl FatalError
  112. IT0030              ANOP
  113.  
  114.                     PushWord MyID
  115.                     lda DPPointer
  116.                     clc
  117.                     adc #MenuDPage
  118.                     pha
  119.                     _MenuStartUp
  120.                     bcc IT0035
  121.                     brl FatalError
  122. IT0035              ANOP
  123.                     PushWord MyID
  124.                     lda DPPointer
  125.                     clc
  126.                     adc #LEDPage
  127.                     pha
  128.                     _LEStartUp
  129.                     bcc IT0040
  130.                     brl FatalError
  131. IT0040              ANOP
  132.                     PushWord MyID
  133.                     _DialogStartup
  134.                     bcc IT0045
  135.                     brl FatalError
  136. IT0045              ANOP
  137.                     _ScrapStartup       ; No errors possible for this call
  138.  
  139.                     _DeskStartup        ; No error possible for this call
  140.  
  141.                     PushWord MyID
  142.                     lda DPPointer
  143.                     clc
  144.                     adc #FMDPage
  145.                     pha
  146.                     _FMStartUp
  147.  
  148.                     PushLong #0
  149.                     _RefreshDeskTop
  150.  
  151. ;
  152. ; Create the menus I need
  153. ;
  154.  
  155.                     ldx #MenuPtrLen-4   ; Get a pointer to the last menu        
  156. loop                phx                 ; Save menu table index on the stack
  157.                     pha                 ; Push on space for the menu handle
  158.                     pha                 ;   returned by NewMenu
  159.                     lda MenuPtr+2,x     ; Push on the pointer to the template
  160.                     pha                 ;   to be used by NewMenu when
  161.                     lda MenuPtr,x       ;   creating the menu
  162.                     pha
  163.                     _NewMenu            ; Create a new menu
  164.                     PushWord #0         ; Tell InsertMenu where to put it
  165.                     _InsertMenu         ; Insert it.
  166.                     plx                 ; Get our index back off the stack
  167.                     dex                 ; Point to the next template pointer
  168.                     dex
  169.                     dex
  170.                     dex
  171.                     bpl loop            ; Go back up if not done yet.
  172.  
  173.                     PushWord #1         ; Add NDA's
  174.                     _FixAppleMenu
  175.  
  176.                     pha                 ; Now call CalcMenuSize for all menus
  177.                     _FixMenuBar
  178.                     PullWord MenuHeight
  179.  
  180.                     _DrawMenuBar        ; Finally, draw it.
  181.  
  182.                     RTS
  183.  
  184. ToolTable           dc i2'8'            ; Data Block for LoadTools call
  185.                     dc i2'14,$0100'     ; Window Manager
  186.                     dc i2'15,$0100'     ; Menu Manager
  187.                     dc i2'16,$0100'     ; Control Manager
  188.                     dc i2'18,$0100'     ; QD Aux
  189.                     dc i2'20,$0100'     ; LineEdit tool set
  190.                     dc i2'21,$0100'     ; Dialog Manager
  191.                     dc i2'22,$0100'     ; Scrap manager
  192.                     dc i2'27,$0100'     ; Font Manager
  193.                     
  194.                     end
  195.  
  196.                     EJECT
  197. *******************************************************************************
  198. *
  199. FatalError          start
  200. *
  201. * Description:      Routine that is called whenever a tool sends back an error
  202. *                   that can not be recovered from. This routine prints the
  203. *                   error on the screen, waits for a keypress then quits back
  204. *                   to whoever started this application up!
  205. *
  206. *
  207. * Inputs:           A = Error number
  208. *
  209. * Outputs:          NONE (program exits)
  210. *
  211. * External Refs:
  212. *                   Import CloseTools
  213. *
  214. * Entry Points:     NONE
  215. *
  216. *******************************************************************************
  217.                     using Globals
  218.  
  219.                     pha                 ; Push the error code
  220.                     PushLong #ErrNumStr ; Address of storage area
  221.                     PushWord #4         ; Length of string
  222.                     _Int2Hex
  223.  
  224.                     _GrafOff            ; If QD Started, shut off graphics
  225.  
  226.                     PushLong #ErrStr    ; Write error message to the screen
  227.                     _WriteCString
  228.  
  229.                     pha                 ; Space for result
  230.                     PushWord #0         ; No echo
  231.                     _ReadChar           ; Wait for a key to be pressed
  232.                     pla                 ; Discard the key
  233.  
  234.                     jsr CloseTools      ; Shut down all the tools in case
  235. ;                                         any got started up
  236.  
  237.                     _Quit QuitParms     ; Quit back to where we came from.
  238.  
  239.                     brk $FF             ; If the quit fails then just break
  240.                     
  241. ErrStr              dc c'A fatal error has occured $'
  242. ErrNumStr           dc c'xxxx   press any key to exit',i1'0'
  243.  
  244.                     end
  245.  
  246.                     EJECT
  247. *******************************************************************************
  248. *
  249. CloseTools          start
  250. *
  251. * Description:      Shut down the tools I started.
  252. *
  253. *
  254. * Inputs:           NONE
  255. *
  256. * Outputs:          NONE
  257. *
  258. * External Refs:    NONE
  259. *
  260. * Entry Points:     NONE
  261. *
  262. *******************************************************************************
  263.                     using Globals
  264.  
  265.                     _FMShutDown
  266.                     _DeskShutDown
  267.                     _ScrapShutDown
  268.                     _DialogShutDown
  269.                     _LEShutDown
  270.                     _MenuShutDown
  271.                     _CtlShutDown
  272.                     _WindShutDown
  273.                     _EMShutDown
  274.                     _QDAuxShutDown
  275.                     _QDShutDown
  276.                     _MTShutDown
  277.  
  278.                     PushLong DPHandle   ; Dispose of all that DP memory
  279.                     _DisposeHandle
  280.  
  281.                     PushWord MyID
  282.                     _MMShutDown
  283.                     _TLShutDown
  284.  
  285.                     rts
  286.                     end
  287.  
  288.  
  289.                     EJECT
  290. *******************************************************************************
  291. *
  292. doQuit              start
  293. *
  294. * Description:      Quit routine. Set the QuitFlag to TRUE for the EventLoop.
  295. *
  296. *
  297. * Inputs:           NONE
  298. *
  299. * Outputs:          QuitFlag set to $FFFF
  300. *
  301. * External Refs:    NONE
  302. *
  303. * Entry Points:     NONE
  304. *
  305. *******************************************************************************
  306.                     using Globals
  307.  
  308.                     lda #$FFFF
  309.                     sta QuitFlag
  310.                     rts
  311.                     end
  312.